package com.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dao.CommentsDao;
import com.util.R;

import javax.annotation.Resource;

@Service
public class CommentsServiceImpl implements CommentsService {
    @Autowired
    CommentsDao commentsDao;

    @Override
    public R getComments(Integer id) {
        R r = new R();
        try {
            r.setData(commentsDao.getComments(id));
        } catch (Exception e) {
            r.setMessage("NO");
            r.setError(e.getMessage());
        }
        return r;
    }

    @Override
    public R addComment(Integer id, String content) {
        R r = new R();
        try {
            r.setData(commentsDao.addComment(id, content));
        } catch (Exception e) {
            r.setMessage("NO");
            r.setError(e.getMessage());
        }
        return r;
    }
}
